package edu.pku.sei.mte.mtemodel.graph;

import edu.pku.sei.mte.utilities.Visitor;


@SuppressWarnings("unchecked")
public class SubGraph<NODE extends GraphNode,EDGE extends GraphEdge,HOST extends Graph<NODE,EDGE>> extends Graph<NODE,EDGE> {
	private HOST host;

	public HOST getHost() {
		return host;
	}

	public void setHost(HOST host) {
		this.host = host;
	}

	@Override
	public void addEdge(EDGE edge) {
		basicAddEdge(edge);
	}

	@Override
	public void addNode(NODE node) {
		basicAddNode(node);
	}

	@Override
	protected void basicAddEdge(GraphEdge graphEdge) {
		this.getEdges().add((EDGE) graphEdge);
	}

	@Override
	protected void basicAddNode(GraphNode graphNode) {
		this.getNodes().add((NODE) graphNode);
	}

	@Override
	protected boolean basicRemoveEdge(EDGE graphEdge) {
		this.getEdges().remove(graphEdge);
		return true;
	}

	@Override
	protected boolean basicRemoveNode(NODE graphNode) {
		this.getNodes().remove(graphNode);
		return true;
	}

	@Override
	public boolean removeEdge(EDGE edge) {
		return basicRemoveEdge(edge);
	}

	@Override
	public boolean removeNode(NODE node) {
		return basicRemoveNode(node);
	}
	
	@Override
	public Object accept(Visitor visitor) {
		return visitor.visitSubGraph(this);
	}
}
